package com.hzjh.h5mall.ui

import android.content.Intent
import com.hzjh.base.ext.frame.JHBaseActivity
import com.hzjh.base.ext.frame.JHBaseVM
import com.hzjh.base.ext.route.RouteUrl
import com.hzjh.base.utils.other.CommUtils
import com.hzjh.base.web.util.WebCacheUtil
import com.hzjh.h5mall.BuildConfig
import com.hzjh.h5mall.databinding.ActivityStartBinding
import com.hzjh.h5mall.ui.web.JSBridge

class StartActivity : JHBaseActivity<ActivityStartBinding,JHBaseVM>() {
    override fun initData() {
        CommUtils.getHandler().postDelayed({
            goHome()
        },2000)
    }

    override fun initView() {
        WebCacheUtil.preLoadUrl(this,BuildConfig.h5Url){
            it.addJsBridge(JSBridge(it))
        }
    }

    override fun initViewBinding(): ActivityStartBinding {
        return ActivityStartBinding.inflate(layoutInflater)
    }

    private fun goHome(){
        val intent = Intent(this, MainActivity::class.java)
        intent.putExtra(RouteUrl.PARAMS_WEB_URL, BuildConfig.h5Url)
        startActivity(intent)
        overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
        finish()
    }
}